/*
 * > /*
>  * INSANE - Interactive Structural Analysis Environment
>  *
>  * Copyright (C) 2003-2004
>  * Universidade Federal de Minas Gerais
>  * Escola de Engenharia
>  * Departamento de Engenharia de Estruturas
>  *
>  * Author's email :     insane@dees.ufmg.br
>  * Author's Website :   http://www.dees.ufmg.br/insane
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
> 1307, USA.
 *
 */

package br.ufmg.dees.insane.ui.rich.learn.learn_view;


/**
 *
 * @author  krishna
 * @version
 */
public class HtmlMSFormatter extends MatrixSystemFormatter {
    
    
    /** Creates new HtmlMSFormatter */
    public HtmlMSFormatter(LearnInterface parent) {
        //msa = new MatrixStructuralAnalysis(parent.getModel().getDModel());
        //rows = msa.numberingAll();
        //cols = rows = 20;
        //A = new GMatrix(msa.addGlobalMatrix());
        //B = new GVector(msa.addGlobalVector());
        //X = new GVector(msa.solver());
        //ATitle = "Stiffness";
        //BTitle =  "Forces";
        //XTitle = "Displacements";
        //rowLabels = new String[rows];
        //colLabels = new String[cols];
        /*for (int i = 0; i < rows; i++) {
            rowLabels[i] = new String("" + (i + 1));
        }*/
        //colLabels = rowLabels;
    }
    
    public String format() {
        StringBuffer str = new StringBuffer("<HTML>");
        
        str.append("<HEAD>");
        str.append("<TITLE>Matrix System AxX=B</TITLE>");
        str.append("<META NAME='Generator' CONTENT='FEMJava 1.0'>");
        str.append("</HEAD>");
        
        str.append("<BODY>");
        
        str.append("<TABLE CELLSPACING=0 CELLPADDING=1>");
        
        str.append("<TR>");
        str.append("<TD COLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD COLSPAN=" + cols + ">");
        str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'><B>" + ATitle + "</B></FONT>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD COLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD>");
        str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'><B>" + XTitle + "</B></FONT>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("<TD>");
        str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'><B>" + BTitle + "</B></FONT>");
        str.append("</TD>");
        str.append("<TD WIDTH=1 BGCOLOR=#FFFFFFF>");
        str.append("</TD>");
        str.append("</TR>");
        str.append("<TR>");
        str.append("<TD COLSPAN=" + (cols + 11) + ">");
        str.append("</TD>");
        str.append("</TR>");

        for (int i = 0; i < rows; i++) {
            str.append("<TR>");
            str.append("<TD BGCOLOR=#BEBEBE>");
            str.append("<FONT SIZE='-2' COLOR=#000000 FACE='Arial, Helvetica'>" + rowLabels[i] + "</FONT>");
            str.append("</TD>");
            str.append("<TD WIDTH=1 BGCOLOR=#FFFFFF>");
            str.append("</TD>");
            str.append("<TD WIDTH=1 BGCOLOR=#000000>");
            str.append("</TD>");
            for(int j = 0; j < cols; j++) {
                str.append("<TD>");
                //str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'> " + A.getElement(i, j) + " </FONT>");
                str.append("</TD>");
            }
            str.append("<TD WIDTH=1 BGCOLOR=#000000>");
            str.append("</TD>");
            if ((int)rows/2 == i) {
                str.append("<TD>");
                str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'><B> x </B></FONT>");
                str.append("</TD>");
            }else{
                str.append("<TD BGCOLOR=#FFFFFFF>&nbsp;");
                str.append("</TD>");
            }
            str.append("<TD WIDTH=1 BGCOLOR=#000000>");
            str.append("</TD>");
            str.append("<TD>");
            //str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'> " + X.getElement(i) + " </FONT>");
            str.append("</TD>");
            str.append("<TD WIDTH=1 BGCOLOR=#000000>");
            str.append("</TD>");
            if ((int)rows/2 == i) {
                str.append("<TD>");
                str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'><B> = </B></FONT>");
                str.append("</TD>");
            }else{
                str.append("<TD BGCOLOR=#FFFFFFF>&nbsp;");
                str.append("</TD>");
            }
            str.append("<TD WIDTH=1 BGCOLOR=#000000>");
            str.append("</TD>");
            str.append("<TD>");
            //str.append("<FONT SIZE='-1' COLOR=#000000 FACE='Arial, Helvetica'> " + B.getElement(i) + " </FONT>");
            str.append("</TD>");
            str.append("<TD WIDTH=1 BGCOLOR=#000000>");
            str.append("</TD>");
            str.append("</TR>");
        }
        
        str.append("</TABLE>");
        str.append("</BODY>");
        str.append("</HTML>");
        return str.toString();
    }
    
}
